﻿using System;
using System.Collections.Generic;

namespace Domain.Models
{
    [Serializable]
    public class Variant
    {
        public int Number { get; private set; }
        private int trueAnswersCount;
        public List<Question> Questions { get; private set; }
        public long Id { get; private set; }

        public Variant(int number)
        {
            Number = number;
            Questions = new List<Question>();
            Id = GetHashCode();
            trueAnswersCount = 0;
        }

        public void AddQuestion(Question newQuestion)
        {
            Questions.Add(newQuestion);
        }

        public int GetNumberOfTrueAnwers()
        {
            return trueAnswersCount;
        }

        public void AnswerQuestion(int questionNumber, string answer)
        {
            var isTrueAnswer = Questions[questionNumber].AnswerToQuestion(answer);
            if (isTrueAnswer)
                trueAnswersCount++;
        }

        public void AnswerQuestion(string question, string answer)
        {
            var isTrueAnswer = Questions.Find(x => x.Text == question).AnswerToQuestion(answer);
            if (isTrueAnswer)
                trueAnswersCount++;
        }


    }
}